﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace TCS.Web
{
    public partial class List : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                  if ((Request.Params["cid"] != null) && (Request.Params["cid"].ToString() != ""))
                {
                    ViewState["cid"] = Request.Params["cid"];
                    ltrClassName.Text = new TCS.BLL.NewsManage.NewsClass().GetModel(int.Parse(Request.Params["cid"].ToString())).ClassDesc;
                }
                BindData();
                BindLeft();
            }
        }
        void BindLeft()
        {
            DataSet ds = new TCS.BLL.Products.Product().GetImgListByCategoryID(10, "");
            this.rptImgList.DataSource = ds;
            this.rptImgList.DataBind();

            DataSet dsNews = new TCS.BLL.NewsManage.News().GetNewsTopList(8, -1);
            this.rptHotList_Left.DataSource = dsNews;
            this.rptHotList_Left.DataBind();
        }
        void BindData()
        {
            string strWhere = " (1=1)";
            int cid = -1;
            if ((ViewState["cid"] != null) && (ViewState["cid"].ToString() != ""))
            {
                cid = int.Parse(ViewState["cid"].ToString());
                
            }
            strWhere+=" and ClassId="+cid;
            TCS.BLL.NewsManage.News bll = new TCS.BLL.NewsManage.News();
            AspNetPager1.RecordCount = bll.GetNewsCountByPage(strWhere);
            DataSet ds = bll.GetNewsListByPage(this.AspNetPager1.PageSize, this.AspNetPager1.CurrentPageIndex, strWhere);//
            this.rptList.DataSource = ds;
            this.rptList.DataBind();
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            BindData();
        }
    }
}
